import Vue from 'vue'
import VueRouter from 'vue-router'

//导入模块路由

import home from './routes/home'
import order from './routes/order'
import center from './routes/center'
Vue.use(VueRouter)
const routes = [
  ...home,
  order,
  ...center,
  // 404
  { path: '*', component: () => import(/*webpackChunkName: '404' */'@/views/Notfound') }
]
const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})
//
// // 全局路由前置守卫 //可以一进页面就定位
// router.beforeEach((to,from,next)=>{
//   if(to.path === '/login') return next()
//   const tokenStr = window.sessionStorage.getItem('token')
//   if(!tokenStr) return next('/login')

//   next()
// })

export default router
